<?php
/**
 *
 * @author crystal
 * @version 
 */
require_once 'Zend/View/Interface.php';

/**
 * BlockNews helper
 *
 * @uses viewHelper Zend_View_Helper
 */
class Zend_View_Helper_BlockUser {
	
	/**
	 * @var Zend_View_Interface 
	 */
	public $view;
	
	/**
	 * 
	 */
	public function blockUser($user, $role = null, $allRoles) {
	   //var_dump($user); die();
		$res = "";
		$res .= "<tr>";
            $res .= "<td>";
                if ($user['role'] != null && isset($allRoles[$user['role']])){
                    
        			$res .= $allRoles[$user['role']];
        		} else {
                    $res .= "no_role";
        		}
            $res .= "</td>";
            $res .= "<td>";
                if ($user['surname'] != null){
        			$res .= $user['surname'];
        		} else {
                    $res .= "no_urname";
        		}
            $res .= "</td>";
            $res .= "<td>";
                if ($user['name'] != null){
        			$res .= $user['name'];
        		} else {
                    $res .= "no_name";
        		}
            $res .= "</td>";
            $res .= "<td>";
                if ($user['patronymic'] != null){
        			$res .= $user['patronymic'];
        		} else {
                    $res .= "no_patronymic";
        		}
            $res .= "</td>";
            $res .= "<td>";
                if ($user['login'] != null){
        			$res .= $user['login'];
        		} else {
                    $res .= "no_login";
        		}
            $res .= "</td>";
            $res .= "<td>";
                if ($user['password'] != null){
                    $res .= $user['password'];
        		} else {
                    $res .= "password";
        		}
            $res .= "</td>";
            $res .= "<td>";
                if ($user['uni_code'] != null){
                    $res .= $user['uni_code'];
        		} else {
                    $res .= "no_uni_code";
        		}
            $res .= "</td>";
            $res .= "<td>";
                if ($user['date_create'] != null){
                    $res .= date('o.m.j-H:i', $user['date_create']);
        		} else {
                    $res .= "no_date_create";
        		} 
            $res .= "</td>";
            $res .= "<td>";
                if ($user['date_last_entry'] != null){
                    $res .= date('o.m.j-H:i:s', $user['date_last_entry']);
        		} else {
                    $res .= "no_date_last_entry";
        		}
            $res .= "</td>";
            
            $res .= "<td>";
                $res .= "<a>";
                    $res .= "<div class='button'><a href='" .
						$this->view->url( array('controller' => 'users', 'action' => 'edit', 'id' => $user['id'])) .
						"'>Редагувати</a></div>";
                $res .= "</a>";
                $res .= "<div class='button'><a href='" .
						$this->view->url( array('controller' => 'users', 'action' => 'del', 'id' => $user['id'])) .
						"'>Видалити</a></div>";
            $res .= "</td>";
		$res .= "</tr>";
		return $res;
	}
	
	/**
	 * Sets the view field 
	 * @param $view Zend_View_Interface
	 */
	public function setView(Zend_View_Interface $view) {
		$this->view = $view;
	}
}

